package com.itheima.day11;

import java.util.Scanner;

public class Test7 {
    public static void main(String[] args) {
        int[] arr = {111,222,333,66,78};
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要查找的元素:");
        int num = sc.nextInt();
        //1.定义一个标记位变量
        int index = -1;

        //遍历数组
        for (int i = 0; i < arr.length; i++) {
             if(arr[i] == num){
                 index = i;
             }
        }
        if(index == -1){
            System.out.println(num + "元素不存在");
        }else {
            System.out.println("查找的元素索引为:" + index);
        }
    }
}
